﻿using System;
using System.Configuration;

namespace DuLabs.Classic.Configuration
{
    public class ClassElementCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new ClassElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            if (element == null)
            {
                return null;
            }

            return (element as ClassElement).Name;
        }

        public new ClassElement this[string name]
        {
            get
            {
                return this.BaseGet(name) as ClassElement;
            }
        }

        public ClassElement this[int index]
        {
            get
            {
                return this.BaseGet(index) as ClassElement;
            }
        }

        protected override string ElementName
        {
            get
            {
                return "class";
            }
        }

        public override ConfigurationElementCollectionType CollectionType
        {
            get
            {
                return ConfigurationElementCollectionType.BasicMap;
            }
        }        
    }
}
